package ex.klmy.gov.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by xiaguoqiang on 16/11/2.
 */
public class StringUtils {
    public static String replaceImgUrl(String content){
        String regEx_img = "<IMG.*?(src=\"(.*?)\")";
        Pattern p = Pattern.compile(regEx_img,Pattern.CASE_INSENSITIVE);
        Matcher matcher = p.matcher(content);
        while (matcher.find()) {
            String url = matcher.group(2);
            if(url.contains("/images/")) {
                String a[] = url.split("/images/");
                content = content.replace(url, "http://www.klmyq.gov.cn/images/" + a[1]);
            }else{
                content = content.replace(url, "http://www.klmyq.gov.cn" + url);
            }
        }
        return content;
    }

    public static boolean isInteger(String str) {
        Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
        return pattern.matcher(str).matches();
    }

}
